﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GameBoard
{
    public partial class AreaControl : UserControl
    {
        public readonly int TitleHeight;
        public readonly float MarginHeight;
        public readonly float MarginWidth;

        public AreaControl()
        {
            InitializeComponent();
            TitleHeight = 20;
            MarginHeight = 1.0f;
            MarginWidth = 2.0f;

            Users = new List<string>();
            isEstate = false;
            Owner = null;
        }
        public List<string> Users
        {
            get;
            set;
        }
        public string Title
        {
            set
            {
                lblTitle.Text = value;
                lblTitle.Location = new Point((ClientSize.Width - lblTitle.Size.Width) / 2,
                    (TitleHeight - lblTitle.Height) / 2);
            }
            get
            {
                return lblTitle.Text;
            }
        }
        public string Owner
        {
            set;
            get;
        }
        public bool isEstate
        {
            set;
            get;
        }
        public bool hasHotel
        {
            set;
            get;
        }
        public bool hasCondo
        {
            get;
            set;
        }
        public bool hasInn
        {
            set;
            get;
        }
        private void Area_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            
            Pen pen = new Pen(Brushes.Black,1.0f);
            Rectangle rect = ClientRectangle;
            rect.Height -= 1;
            rect.Width -= 1;
            g.DrawLine(pen, new Point(1, TitleHeight), new Point(rect.Width, TitleHeight));
            g.DrawRectangle(pen, rect);
            float currentHeight = TitleHeight;
                Brush brush=Brushes.Black;
            
            if (isEstate)
            {
                currentHeight += 2.0f * MarginHeight;
                g.DrawString("+" + Owner,Font,brush,new PointF(MarginWidth,currentHeight));
                currentHeight += (Font.Height + MarginHeight);
                g.DrawLine(pen, 0f, currentHeight, (float)rect.Width, currentHeight);
            }
            foreach (var username in Users)
            {
                g.DrawString("-"+username, Font, brush, new PointF(MarginWidth, currentHeight));
                currentHeight += Font.Height + MarginHeight;
            }
        }
    }
}
